package com.sdhs.projectstart.controller;

import com.sdhs.common.annotation.Log;
import com.sdhs.common.core.controller.BaseController;
import com.sdhs.common.core.domain.AjaxResult;
import com.sdhs.common.core.page.TableDataInfo;
import com.sdhs.common.enums.BusinessType;
import com.sdhs.projectstart.domain.ProjectStartWork;
import com.sdhs.projectstart.service.IProjectStartWorkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 项目开工申请信息操作处理
 *
 * @author ww
 */
@RestController
@RequestMapping("/projectStart/projectStartWork")
public class ProjectStartWorkController extends BaseController {
    @Autowired
    private IProjectStartWorkService projectStartWorkService;

    /**
     * 查询项目开工申请列表
     */
    @PreAuthorize("@ss.hasPermi('projectStart:projectStartWork:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectStartWork projectStartWork) {
        startPage();
        List<ProjectStartWork> list = projectStartWorkService.selectProjectStartWorkList(projectStartWork);
        return getDataTable(list);
    }

    /**
     * 获取项目进度控制--开工申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('projectStart:projectStartWork:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(projectStartWorkService.selectProjectStartWorkById(id));
    }
    /**
     * 新增项目开工申请
     */
    @PreAuthorize("@ss.hasPermi('projectStart:projectStartWork:add')")
    @Log(title = "项目开工申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectStartWork projectStartWork) {
        return success(projectStartWorkService.insertProjectStartWork(projectStartWork));
    }

    /**
     * 修改项目开工申请
     */
    @PreAuthorize("@ss.hasPermi('projectStart:projectStartWork:edit')")
    @Log(title = "项目开工申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectStartWork projectStartWork) {
        return toAjax(projectStartWorkService.updateProjectStartWork(projectStartWork));
    }

    /**
     * 删除项目开工申请
     */
    @PreAuthorize("@ss.hasPermi('projectStart:projectStartWork:remove')")
    @Log(title = "项目开工申请", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(projectStartWorkService.deleteProjectStartWorkByIds(ids));
    }
}
